﻿using UnityEngine;
using UnityEngine.UI;

namespace DiverseStudents.UI
{
    internal static partial class UICreate
    {
        public static HorizontalLayoutGroup HorizontalTile(float width,float height)
        {
            GameObject gameObject = new GameObject("Mod_ListTitle", typeof(HorizontalLayoutGroup));
            var hl = gameObject.GetComponent<HorizontalLayoutGroup>();
            if (hl != null)
            {
                hl.childControlWidth = true;
                hl.childForceExpandHeight = false;
                hl.childForceExpandWidth = false;
                hl.childAlignment = TextAnchor.UpperLeft;
            }
            var rt = gameObject.transform as RectTransform;
            rt.sizeDelta = new Vector2(width, height);
            rt.anchorMax = new Vector2 (1,1);
            rt.position += new Vector3((width/0.7f)*0.01f, -height*0.6f, 0);
            var text1 = UICreate.Text(TexTContent.hTitlemodTitle, UICreate.TextType.Tile, fontSize: 30);
            var text1le = text1.gameObject.AddComponent<LayoutElement>();
            text1le.preferredWidth = width * 0.3f;
            text1le.flexibleWidth = 0;
            text1.transform.SetParent(gameObject.transform, false);

            var text2 = UICreate.Text(TexTContent.hTitlemodDesc, UICreate.TextType.Tile, fontSize: 30);
            var text2le = text2.gameObject.AddComponent<LayoutElement>();
            text2le.preferredWidth = width * 0.5f;
            text2le.flexibleWidth = 0;
            text2.transform.SetParent(gameObject.transform, false);

            var text3 = UICreate.Text(TexTContent.hTitlemodLoad, UICreate.TextType.Tile, fontSize: 30);
            var text3le = text1.gameObject.AddComponent<LayoutElement>();
            text3le.preferredWidth = width * 0.2f;
            text3le.flexibleWidth = 0;
            text3.transform.SetParent(gameObject.transform, false);
            return hl;
        }
    }
}
